﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Word_Learner_3.Web;
using Word_Learner_3.Model;

namespace Word_Learner_3
{

    public partial class FloatingText : Form
    {
        private bool w_TopMost;
        private double w_Opacity;

        public void LoadProperty()
        {
            Config config = SerializationHelper.Load(typeof(Config), Application.StartupPath + "\\Configuration.config") as Config;

            w_TopMost = config.ConfigItem[0].TopMost;
            w_Opacity = config.ConfigItem[0].Opacity;

            switch (w_TopMost)
            {
                case true: this.TopMost = true; break;
                case false: this.TopMost = false; break;

            }
            this.Opacity = config.ConfigItem[0].Opacity / 100;


        }
        public FloatingText(int top,int left)
        {
            InitializeComponent();
            this.Top = top;
            this.Left = left;
            LoadProperty();
            label1.Text = "";
            label2.Text = "";
            label3.Text = "";
            label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
            label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form_MouseMove);
            label2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
            label2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form_MouseMove);
            label3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
            label3.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form_MouseMove);
        }
        public void Change(string text1, string text2, string text3)
        {
            label1.Text = text1;
            label2.Text = text2;
            label3.Text = text3;
        }
       

        private Point mypoint;
        private void Form_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
                this.mypoint = new Point(-e.X, -e.Y);
              
        }
        private void Form_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.SetDesktopLocation(this.Left + e.X + this.mypoint.X, this.Top + e.Y + this.mypoint.Y);
            }

        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

       


    }
}
